<template>
	<view>
		<view class="Eventlist">
			<scroll-view lower-threshold="500" @scrolltolower='nextPage()' scroll-y="true"
				:style="{height:teamHeight+'px'}">
				<view class="null box-c d-jc-c d-ai-c" v-if="isShow">
					<image class="mt-5" src="../../static/images/activity/shenqing@2x.png" mode=""></image>
					<text class="mt-3">您暂时还没活动记录~</text>
				</view>
				<view class="teamScroll" v-if="!isShow">
					<view class="Introuce_content" v-for="(item,index) in Ujoinactivity" :key="index">
						<view class="Introuce_top box d-jc-sb d-ai-c">
							<view class="">
								加入时间：{{item.updateTime}}
							</view>
							<view class="" v-if="item.joinStatus==0">
								已通过
							</view>
							<view class="" v-if="item.joinStatus==1">
								审核中
							</view>
							<view class="" v-if="item.joinStatus==2">
								拒绝
							</view>
							<view class="" v-if="item.joinStatus==3">
								已退出
							</view>
						</view>
						<view class="Introuce_item box d-jc-sb">
							<image class="team_image3" :src="item.logo" mode=""></image>
							<view class="c_b">
								<view class="">
									{{item.title}}
								</view>
								<view class="c_t">
									<view class="">
										{{item.applyStartTime}}到{{item.applyEndTime}}
									</view>
									<view class="">
										{{item.city}}{{item.district}}{{item.address}}
									</view>
								</view>
							</view>
						</view>
						<view class="Introuce_bottom" v-if="item.joinStatus==0" @tap="exitactivity(item.id)">
							退出活动
						</view>
						<view class="Introuce_bottom" v-if="item.joinStatus==2" @tap="exitactivity(item.id)">
							仍要退出
						</view>
					</view>
					

				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				teamHeight: '',
				Ujoinactivity:'',
				isShow:false,
				activityUnityId:'',
				activityId:''
			}
		},
		onReady() {
			let that = this;
			uni.getSystemInfo({ //调用uni-app接口获取屏幕高度
				success(res) { //成功回调函数
					that.teamHeight = res.windowHeight - uni.upx2px(0) //windoHeight为窗口高度，主要使用的是这个
				}
			})

		},
		onNavigationBarButtonTap() {
			uni.navigateTo({
				url: '/pages/teamcenter/createTeam',
				animationDuration: 350
			})
		},
		onLoad(option) {
			console.log(option.teamid)
			this.activityUnityId = option.teamid
			this.joinedactivity(option.teamid)
		},
		methods: {
			//退出活动/仍要退出
			exitactivity(id){
				uni.showModal({
				    title: '提示',
				    content: '确定退出此活动？',
				    success:(res)=> {
				        if (res.confirm) {
				            console.log('用户点击确定');
							this.$api.exitactivity({
								activityUnityId: this.activityUnityId,
								activityId:id
							}).then((res) => {
								if (res.data.code == 200) {
									console.log(res.data.dataMap)
									uni.showToast({
										title: "等待审核",
										duration: 1500,
										icon: "none"
									});
									this.joinedactivity(this.activityUnityId)
								}
							})
				        } else if (res.cancel) {
				            console.log('用户点击取消');
				        }
				    }
				});
			},
			//关联活动
			joinedactivity(id) {
				this.$api.joinedactivity({
					activityUnityId: id,
				}).then((res) => {
					if (res.data.code == 200) {
						console.log(res.data.dataMap)
						this.Ujoinactivity = res.data.dataMap
						if(this.Ujoinactivity.length<1){
							this.isShow=true
						}else{
							this.isShow=false
						}
					}
				})
			},

		}
	}
</script>

<style scoped>
	.null>image {
		width: 340rpx;
		height: 340rpx;	
	}	
	.null>text{
		color: #8b8b8b;
	}
	.Introuce_bottom{
		float: right;
		width: 160rpx;
		height: 60rpx;
		background: #FFFFFF;
		border: 2rpx solid #CCCCCC;
		border-radius: 30rpx;
		font-size: 22rpx;
		font-weight: 500;
		color: #666666;
		text-align: center;
		line-height: 60rpx;
	}
	.Introuce_top{
		width: 630rpx;
		height: 90rpx;
		margin: 0 auto;
		border-bottom:2rpx solid #EEEEEE;
	}
	.Introuce_top>view:nth-child(1){
		font-size: 24rpx;
		font-weight: 500;
		color: #666666;
	}
	.Introuce_top>view:nth-child(2){
		font-size: 24rpx;
		font-weight: 500;
		color: #FF7E51;
	}
	.Eventlist {
		width: 750rpx;
		background: #F8F8F8;
	}
	.teamScroll{
		overflow: hidden;
	}
	.Introuce_content{
		width: 630rpx;
		min-height: 266rpx;
		margin: 0 auto;
		margin-top: 35rpx;
		background-color: #FFFFFF;
		padding: 0 30rpx 30rpx 30rpx;
		overflow: hidden;
	}
	.Introuce_item{
		width: 630rpx;
		height: 200rpx;
		margin: 0 auto;
		background-color: #FFFFFF;
		margin-top: 20rpx;
	}
	.c_b>view:nth-child(1){
		font-size: 28rpx;
		font-weight: 500;
		color: #333333;
		line-height: 36rpx;
	}
	.c_t{
		position: absolute;
		bottom: -110rpx;
	}
	.c_t>view:nth-child(1){
		width: 380rpx;
		font-size: 22rpx;
		font-weight: 500;
		color: #999999;
	}
	.c_t>view:nth-child(2){
		width: 380rpx;
		font-size: 22rpx;
		font-weight: 500;
		color: #999999;
		white-space: nowrap;
		text-overflow: ellipsis;
		overflow: hidden;
	}
	.c_b{
		width: 358rpx;
		height: 60rpx;
		position: relative;
	}
	.team_image3{
		width: 250rpx;
		height: 164rpx;
		border-radius: 8rpx;
	}
</style>
